package frontend

import (
	"blog/service/page"
	"net/http"
	"strconv"

	"github.com/gin-gonic/gin"
)

/*
*
归档
*/
func ArchiveHandle(ctx *gin.Context) {
	//页号
	pageId, err := strconv.ParseInt(ctx.Query("page"), 10, 64)
	if err != nil {
		pageId = 1
	}
	if pageId < 1 {
		pageId = 1
	}

	// 调用 ps 层
	postPageService := page.NewPostPageService()
	postListData := postPageService.GetPostListForIndex(ctx, pageId, 30, 0, false)

	data := gin.H{
		"Data": postListData,
		"Page": pageId,
	}
	ctx.HTML(http.StatusOK, "archive.html", data)
}
